﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ZEBuz.Questionnaire.Lib.Util;

namespace ZEBuz.Questionnaire.Lib.Core
{
    public class Security
    {
        public static int UserId
        {
            get
            {
                if (System.Web.HttpContext.Current.Session["UserId"] == null)
                    return 0;
                else
                    return System.Web.HttpContext.Current.Session["UserId"].ToString().ToInt();
            }
            set
            {
                System.Web.HttpContext.Current.Session["UserId"] = value;
            }
        }

        public Security()
        {
        }

        public static bool IsLogin()
        {
            return UserId > 0;
        }

        public static bool IsAdmin()
        {
            return UserId == 1;
        }

        public static void LoginAdmin()
        {
            UserId = 1;
        }
    }
}
